package com.zhaoxi.demo.models;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * Created by Infor on 2017/07/04.
 */
public class StudentViewModel {

    private int id;
    @NotNull
    @Length(min = 2, max = 10)
    private String name;
    @Range(min = 20, max = 80)
    @NotNull
    private int age;
    @Email
    private String email;
    @Pattern(regexp = "13\\d{9}")
    private String phone;

    public StudentViewModel() {
    }

    public StudentViewModel(Student student) {
        id = student.getId();
        name = student.getName();
        email = student.getEmail();
        phone = student.getPhone();
        age = student.getAge();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}
